<template>
	<div class="wait">加载中---</div>
</template>

<script>
import { getOAuthLoginBackUrl } from '@/common/js/auth.js';
export default {
	name: 'OAuthLoginWaiting',
	data: () => {
		return {};
	},
	methods: {
		getQueryString(name) {
			var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
			var r = window.location.search.substr(1).match(reg); //search,查询？后面的参数，并匹配正则
			if (r != null) {
				return unescape(r[2]);
			}
			return null;
		},
		saveUserInfo() {
			let token = this.getQueryString('token');
			this.$store.commit('user/SET_TOKEN', token);
			this.$store.dispatch('user/GetInfo').then(()=>{
				window.location.href = getOAuthLoginBackUrl();
			});
		}
	},
	mounted() {
		this.saveUserInfo();
	}
};
</script>

<style></style>
